package com.cnpinxi.service;

import com.cnpinxi.dao.PackageRelationMapper;
import com.cnpinxi.domain.PackageRelation;
import com.cnpinxi.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2017-11-16.
 */
@Service
public class PackageRelationServiceImpl implements com.cnpinxi.service.PackageRelationService {
@Autowired
    PackageRelationMapper packageRelationMapper;
    @Override
    public List<PackageRelation> getPackageRelationList(Map<String, String> map) {
        return packageRelationMapper.selectPackageRelationList(map);
    }

    @Override
    public PackageRelation getPackageRelation(Map<String, String> map) {
        return packageRelationMapper.selectPackageRelation(map);
    }

    @Override
    public void modifyPackageRelation(PackageRelation packageRelation) {
        Long packageRelationId = packageRelation.getTid();
        if (packageRelationId == null) {
            insertPackageRelation(packageRelation);
        } else {
            updatePackageRelation(packageRelation);
        }
    }
    private void insertPackageRelation(PackageRelation packageRelation) {
        packageRelationMapper.insertPackageRelation(packageRelation);
    }

    private void updatePackageRelation(PackageRelation packageRelation) {
        packageRelationMapper.updatePackageRelationById(packageRelation);
    }

    @Override
    public void deletePackageRelationById(Long tid) {
        packageRelationMapper.deletePackageRelationById(tid);
    }
}
